package com.sunday.authorization.security.tools.authorization.redis.constants;


public interface RedisOAuth2Constants {


    /***********************************    redis    *****************************************/


    String CACHE_TOKEN_PREFIX = "Oauth2:";

    /**
     * Authorization
     */

    /**
     * 贯穿流程的 id
     */
    String ID_TO_AUTHORIZATION = STR."\{CACHE_TOKEN_PREFIX}id_to_authorization:";

    static String getIdToAuthorization(String id) {
        return ID_TO_AUTHORIZATION + id;
    }

    /**
     * 存储处于初始化状态或尚未完全完成的授权信息
     */
    String STATE_TO_AUTHORIZATION = STR."\{CACHE_TOKEN_PREFIX}state_to_authorization:";

    static String getStateToAuthorization(String state) {
        return STATE_TO_AUTHORIZATION + state;
    }

    /**
     * 未完成授权 code
     */
    String CODE_TO_AUTHORIZATION = STR."\{CACHE_TOKEN_PREFIX}code_to_authorization:";

    static String getCodeToAuthorization(String state) {
        return CODE_TO_AUTHORIZATION + state;
    }

    /**
     * 完成授权 访问token
     */
    String ACCESS_TO_AUTHORIZATION = STR."\{CACHE_TOKEN_PREFIX}access_to_authorization:";

    static String getAccessToAuthorization(String accessToken) {
        return ACCESS_TO_AUTHORIZATION + accessToken;
    }

    /**
     * 完成授权 刷新token
     */
    String REFRESH_TO_AUTHORIZATION = STR."\{CACHE_TOKEN_PREFIX}refresh_to_authorization:";

    static String getRefreshToAuthorization(String refreshToken) {
        return REFRESH_TO_AUTHORIZATION + refreshToken;
    }

    /**
     * 登录账号 principalName
     */
    String PRINCIPAL_NAME = STR."\{CACHE_TOKEN_PREFIX}principalName:";

    static String getPrincipalName(String principalName) {
        return PRINCIPAL_NAME + principalName;
    }

    /**
     * Consent
     */
    String ID_TO_CONSENT = STR."\{CACHE_TOKEN_PREFIX}id_to_consent:";

    static String getIdToConsent(int id) {
        return ID_TO_CONSENT + id;
    }

}
